<?php

namespace app\common\model;

use think\Model;


class CheckInput extends Model
{

    

    

    // 表名
    protected $name = 'check_input';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_check_require_switch_text',
        "check_item_json_array",
    ];


    public function getCheckItemJsonArrayAttr($value, $data)
    {
        if (empty($data["check_item_json"])) return [];
        return json_decode($data["check_item_json"],true);
    }
    
    public function getIsCheckRequireSwitchList()
    {
        return ['1' => __('Is_check_require_switch 1'), '0' => __('Is_check_require_switch 0')];
    }


    public function getIsCheckRequireSwitchTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_check_require_switch']) ? $data['is_check_require_switch'] : '');
        $list = $this->getIsCheckRequireSwitchList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function check()
    {
        return $this->belongsTo('Check', 'check_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function getIsFestivalSwitchSwitchList()
    {
        return ['1' => __('是'), '0' => __('否')];
    }
}
